package com.aboo.infrastructure.base.enums;

import java.util.HashMap;
import java.util.Map;

public enum FlagEnum {
	
	YES("Y", "成功"),
	NO("N", "失败");
	
	private String value;
	private String text;
	
	private FlagEnum(String value, String text) {
		this.value = value;
		this.text = text;
	}
	
	public static Map<String, String> getMap() {
		Map<String, String> map = new HashMap<>(8);
		FlagEnum[] systemArr = FlagEnum.values();
		for (FlagEnum system : systemArr) {
			map.put(String.valueOf(system.getValue()), system.getText());
		}
		
		return map;
	}
	
	public static String getText(String value) {
		FlagEnum[] systemArr = FlagEnum.values();
		for (FlagEnum system : systemArr) {
			if (value.equals(system.getValue()))
				return system.getText();
		}
		
		return null;
	}
	
	public static FlagEnum getEnum(String value) {
		FlagEnum[] systemArr = FlagEnum.values();
		for (FlagEnum system : systemArr) {
			if (value.equals(system.getValue()))
				return system;
		}
		
		return null;
	}

	public String getValue() {
		return value;
	}

	public String getText() {
		return text;
	}

}
